from game.client.gui.text import *
from game.client.gui.widget import *
import pygame

from game.client.gamestate.gamestate import *


class FreeState(GameState):

    def __init__(self):
        GameState.__init__(self)

    def begin(self, data):
        data.camera.set_mode('fps')
        lbl = FpsLabel(data.clock, x=20, y=20, width=128, height=64, color=(0,255,255,255))
        #lbl.pos.set_size((128, 64))
        data.gui.add_widget(lbl)

    def resume(self, data):
        data.camera.set_mode('fps')

    def event(self, data, event, ms):
        if event.type == QUIT:
            data.quit_game()
            return
        elif event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                data.state.push_state(data, 'main_menu')

        data.gui.event(event, ms)
        data.model.input_hook(event,ms) #TODO: Rename this so it is consistent
        data.camera.event(event, ms)
        data.player.event(event, ms)


    def update(self, data, ms):
        data.camera.update(ms)
        data.gui.update(ms)
        data.player.update(ms)

    def draw(self, data):
        data.renderer.render()
        data.gui.draw()